import 'package:guochaoapp/model/order_list_entity.dart';

orderListEntityFromJson(OrderListEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new OrderListData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> orderListEntityToJson(OrderListEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

orderListDataFromJson(OrderListData data, Map<String, dynamic> json) {
	if (json['records'] != null) {
		data.records = new List<OrderListDataRecord>();
		(json['records'] as List).forEach((v) {
			data.records.add(new OrderListDataRecord().fromJson(v));
		});
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['size'] != null) {
		data.size = json['size'] is String
				? int.tryParse(json['size'])
				: json['size'].toInt();
	}
	if (json['current'] != null) {
		data.current = json['current'] is String
				? int.tryParse(json['current'])
				: json['current'].toInt();
	}
	if (json['orders'] != null) {
		data.orders = new List<dynamic>();
		data.orders.addAll(json['orders']);
	}
	if (json['searchCount'] != null) {
		data.searchCount = json['searchCount'];
	}
	if (json['pages'] != null) {
		data.pages = json['pages'] is String
				? int.tryParse(json['pages'])
				: json['pages'].toInt();
	}
	return data;
}

Map<String, dynamic> orderListDataToJson(OrderListData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.records != null) {
		data['records'] =  entity.records.map((v) => v.toJson()).toList();
	}
	data['total'] = entity.total;
	data['size'] = entity.size;
	data['current'] = entity.current;
	if (entity.orders != null) {
		data['orders'] =  [];
	}
	data['searchCount'] = entity.searchCount;
	data['pages'] = entity.pages;
	return data;
}

orderListDataRecordFromJson(OrderListDataRecord data, Map<String, dynamic> json) {
	if (json['mallOrderNo'] != null) {
		data.mallOrderNo = json['mallOrderNo'].toString();
	}
	if (json['mallOrderStatus'] != null) {
		data.mallOrderStatus = json['mallOrderStatus'].toString();
	}
	if (json['receiverAddr'] != null) {
		data.receiverAddr = json['receiverAddr'].toString();
	}
	if (json['createAt'] != null) {
		data.createAt = json['createAt'].toString();
	}
	if (json['paymentPrice'] != null) {
		data.paymentPrice = json['paymentPrice'] is String
				? double.tryParse(json['paymentPrice'])
				: json['paymentPrice'].toDouble();
	}
	if (json['returnPrice'] != null) {
		data.returnPrice = json['returnPrice'] is String
				? double.tryParse(json['returnPrice'])
				: json['returnPrice'].toDouble();
	}
	if (json['numTotal'] != null) {
		data.numTotal = json['numTotal'] is String
				? int.tryParse(json['numTotal'])
				: json['numTotal'].toInt();
	}
	return data;
}

Map<String, dynamic> orderListDataRecordToJson(OrderListDataRecord entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['mallOrderNo'] = entity.mallOrderNo;
	data['mallOrderStatus'] = entity.mallOrderStatus;
	data['receiverAddr'] = entity.receiverAddr;
	data['createAt'] = entity.createAt;
	data['paymentPrice'] = entity.paymentPrice;
	data['returnPrice'] = entity.returnPrice;
	data['numTotal'] = entity.numTotal;
	return data;
}